<template>
	<view class="container">
		<block>
			<!-- s -->
			<view v-if="logintype>0" style="width:100%;height: 100%;">
				<view class="bg_div1"
					:style="loginset_data.bgtype==1?'background:'+loginset_data.bgcolor:'background:url('+loginset_data.bgimg+') no-repeat center;background-size:100% 100%'">
					<view style="overflow: hidden;">
						<view v-if="loginset_type==1" style="width: 700rpx;margin: 0 auto;">
							<view class="title1"
								:style="'color:'+loginset_data.titlecolor+';text-align: '+loginset_data.titletype">
								{{loginset_data.title}}
							</view>
						</view>

						<view style="text-align: center;">
							<img :src="logo" style="height: 400rpx;" mode="aspectFit">
							<!-- <view class="title">
								师傅协议须知
							</view> -->
						</view>
						
						
						

						<view class="content_div1">
								<view class="card_div1" :style="'background:'+loginset_data.cardcolor">
									
									<view v-if="xystatus==1"
										class="xycss1">
										<checkbox-group @change="isagreeChange" style="display: inline-block;">
											<checkbox style="transform: scale(0.6)" value="1" :checked="isagree" />
											<text
												:style="'color:'+loginset_data.xytipcolor">{{loginset_data.xytipword}}</text>
										</checkbox-group>
										<text @tap="showxieyiFun"
											:style="'color:'+loginset_data.xycolor">{{xyname}}</text>
										<text @tap="showxieyiFun" v-if="xyname2"
											:style="'color:'+loginset_data.xytipcolor">和</text>
										<text @tap="showxieyiFun2" v-if="xyname2"
											:style="loginset_data.xycolor?'color:'+loginset_data.xycolor:'color:'+t('color1')">{{xyname2}}</text>
									</view>

									<view style="margin-top: 40rpx;">
										<block >
											<button  @tap="authlogin" 
												class="btn1"
												:style="'background:rgba('+t('color1rgb')+');color: '+loginset_data.btnwordcolor">
												<block>
													同意并实名认证
												</block>
											</button>
										</block>

										<button class="btn1" @tap="goback"
											style="background-color:#EEEEEE ;font-size: 28rpx;">不同意</button>

									</view>
								</view>
						</view>
					</view>
				</view>
			</view>
			<!-- e -->

			<view v-if="showxieyi" class="xieyibox">
				<view class="xieyibox-content">
					<view style="overflow:scroll;height:100%;">
						<parse :content="xycontent" @navigate="navigate"></parse>
					</view>
					<view
						style="position:absolute;z-index:9999;bottom:10px;left:0;right:0;margin:0 auto;text-align:center; width: 50%;height: 60rpx; line-height: 60rpx; color: #fff; border-radius: 8rpx;"
						:style="{background:'linear-gradient(90deg,'+t('color1')+' 0%,rgba('+t('color1rgb')+',0.8) 100%)'}"
						@tap="hidexieyi">已阅读并同意</view>
				</view>
			</view>
			<view v-if="showxieyi2" class="xieyibox">
				<view class="xieyibox-content">
					<view style="overflow:scroll;height:100%;">
						<parse :content="xycontent2" @navigate="navigate"></parse>
					</view>
					<view
						style="position:absolute;z-index:9999;bottom:10px;left:0;right:0;margin:0 auto;text-align:center; width: 50%;height: 60rpx; line-height: 60rpx; color: #fff; border-radius: 8rpx;"
						:style="{background:'linear-gradient(90deg,'+t('color1')+' 0%,rgba('+t('color1rgb')+',0.8) 100%)'}"
						@tap="hidexieyi2">已阅读并同意</view>
				</view>
			</view>

		</block>
	</view>
</template>

<script>
	var app = getApp();

	export default {
		data() {
			return {
				opt: {},
				logintype: 0, 
				isioslogin: false,
				isgooglelogin: false,

				logo: '',
				name: '',
				xystatus: 0,
				xyname: '',
				xycontent: '',
				xyname2: '',
				xycontent2: '',
				showxieyi: false,
				showxieyi2: false,
				isagree: false,
				loginset_data: "",
				loginset_type: "",
				mid: 0
			};
		},

		onLoad: function(opt) {
			this.opt = app.getopts(opt);
			wx.getStorage({
			  key: 'worker_login',
			  success: function (res) {
				  if(res.data.worker_admin && app.globalData.is_worker == 0){
					  app.globalData.is_worker++;
					  //师傅已登录跳转到抢单大厅
					  app.goto('/activity/yuyue/dating', 'reLaunch');
				  }
			  },
			  fail: function (res) {
			  },
			});
			this.getdata();
		},
		onShow: function() {

		},
		onPullDownRefresh: function() {
			
		},
		methods: {
			getdata: function() {
				var that = this;
				
				app.post("ApiMy/inspect_worker", {}, function(res) {
					if (res.status == 0) {
						app.alert(res.msg);
						setTimeout(function() {
							app.goto("/pages/my/usercenter", "reLaunch");
						}, 1000);
					}else if(res.status == 1){
						app.goto("/activity/yuyue/dating", "reLaunch");
					}else{
						app.get('ApiIndex/login', {}, function(res) {
							
							if (res.loginset_type) {
								that.loginset_type = res.loginset_type
							}
							if (res.loginset_data) {
								that.loginset_data = res.loginset_data
							}
						
							that.google_client_id = res.google_client_id || '';
							that.login_mast = res.login_mast;
							that.needsms = res.needsms;
							that.reg_invite_code = res.reg_invite_code;
							that.reg_invite_code_text = res.reg_invite_code_text;
							that.parent = res.parent;
							
							that.logintype = 3; //授权登录
							
							that.xystatus = res.xystatus;
							that.xyname = res.xyname;
							that.xycontent = res.xycontent;
							that.xyname2 = res.xyname2;
							that.xycontent2 = res.xycontent2;
							that.logo = res.logo;
							that.name = res.name;
							
							that.loaded();
						});
					}
				});
			},
			
			goback: function(){
				app.goto('/pages/my/usercenter', 'reLaunch');
			},
			
			authlogin: function(e) {
				var that = this;
				if (that.xystatus == 1 && !that.isagree) {
					app.error('请先阅读并同意用户注册协议');
					return false;
				}
				app.goto('authentication');
			},
			
			isagreeChange: function(e) {
				var val = e.detail.value;
				if (val.length > 0) {
					this.isagree = true;
				} else {
					this.isagree = false;
				}
				console.log(this.isagree);
			},
			showxieyiFun: function() {
				this.showxieyi = true;
			},
			hidexieyi: function() {
				this.showxieyi = false;
				this.isagree = true;
			},
			showxieyiFun2: function() {
				this.showxieyi2 = true;
			},
			hidexieyi2: function() {
				this.showxieyi2 = false;
				this.isagree = true;
			},
			
			
		}
	};
</script>

<style>
	page {
		background: #ffffff;
		width: 100%;
		height: 100%;
	}

	.container {
		width: 100%;
		height: 100%;
	}

	.text-center {
		text-align: center;
	}

	.xieyi-item {
		display: flex;
		align-items: center;
		margin-top: 30rpx
	}

	.xieyi-item {
		font-size: 24rpx;
		color: #B2B5BE
	}

	.xieyi-item .checkbox {
		transform: scale(0.6);
	}

	.authlogin {
		display: flex;
		flex-direction: column;
		align-items: center
	}

	.authlogin-logo {
		width: 180rpx;
		height: 180rpx;
		margin-top: 120rpx
	}

	.authlogin-name {
		color: #999999;
		font-size: 30rpx;
		margin-top: 60rpx;
	}

	.authlogin-btn {
		width: 580rpx;
		height: 96rpx;
		line-height: 96rpx;
		background: #51B1F5;
		border-radius: 48rpx;
		color: #fff;
		margin-top: 100rpx
	}

	.authlogin-btn2 {
		width: 580rpx;
		height: 96rpx;
		line-height: 96rpx;
		background: #EEEEEE;
		border-radius: 48rpx;
		color: #A9A9A9;
		margin-top: 20rpx
	}




	.xieyibox {
		width: 100%;
		height: 100%;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 99;
		background: rgba(0, 0, 0, 0.7)
	}

	.xieyibox-content {
		width: 90%;
		margin: 0 auto;
		/*  #ifdef  MP-TOUTIAO */
		height: 60%;
		/*  #endif  */
		/*  #ifndef  MP-TOUTIAO */
		height: 80%;
		/*  #endif  */
		margin-top: 20%;
		background: #fff;
		color: #333;
		padding: 5px 10px 50px 10px;
		position: relative;
		border-radius: 2px;
	}

	

	.content_div1 {
		width: 700rpx;
		margin: 0 auto;
		margin-bottom: 60rpx;
	}

	.card_div1 {
		width: 100%;
		padding: 40rpx;
		border-radius: 24rpx;
		margin-top: 40rpx;
	}


	.btn1 {
		width: 100%;
		height: 100rpx;
		border-radius: 100rpx;
		line-height: 100rpx;
		margin: 20rpx 0;
		text-align: center;
		font-weight: bold;
		color: #A9A9A9;
		font-size: 30rpx
	}

	.title {
		text-align: center;
		opacity: 1;
		font-size: 40rpx;
		font-weight: bold;
	}
	
	



	.xycss1 {
		line-height: 60rpx;
		font-size: 24rpx;
		overflow: hidden;
	}

</style>